using System;
using System.Data;
using System.Configuration;
using System.ComponentModel;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


namespace Data.DataSources {
	public class StateFlowNextStatesDataSource : ObjectDataSourceBase {
		public override bool UseNoLock { get { return false; } }
		public override string DataTableName {
			get { return "NextStatuses"; }
			set { throw new NotImplementedException(); }
		}
		public override string SelectViewName { get { return "fs_NextStates" + SelectPostfix + "(@StateFromID)"; } }
		public override string InsertViewName { get { return ""; } }
		[Bindable(true)]
		public int StateFromID {
			set { SetSelectParameter("StateFromID", value); }
		}

		#region TableID
		/*
		/// <summary>
		/// ID value for fs_NextStates_TableXyz(@XyzID)
		/// <example>fs_NextStates_TableXyz(@XyzID)</example>
		/// </summary>
		[Bindable(true)]
		public int TableID {
			set { SetSelectParameter("ID", value); }
		}
	 */
		/// <summary>
		/// Table Name for fs_NextStates_TableXyz(@XyzID)
		/// <example>fs_NextStates_TableXyz(@XyzID)</example>
		/// </summary> 
		#endregion

		[Bindable(true)]
		public string TableName {
			set { SetSelectParameter("TableName", SQL.CheckInjects(value)); }
		}
		public StateFlowNextStatesDataSource(object stateFromID) :this(){
			StateFromID = Convert.ToInt32(stateFromID);
		}
		public StateFlowNextStatesDataSource() {
			OrderBy.Add("StateFlowPosTo");
		}
		public /*override*/ DataView SelectEx(int ID,string TableName) {
			SelectPostfix = "_" + TableName;
			return Select("", ID);
			//try {
			//	return SQL.ExecuteDataset("SELECT * FROM " + SelectViewName+"_"+TableName + "(@ID)" + OrderBys, ID).Tables[0].DefaultView;
			//} catch(Exception exc) { throw new SmartException(exc); }
		}
		public override DataView SelectEx(int StateFromID) {
			return Select("", StateFromID);
			//try {
			//	DataSet ds = SQL.ExecuteDataset("SELECT * FROM " + SelectViewName + "(@StateFromID)"+OrderBys, StateFromID);
			//	return AddEmptyRow(ds,AddEmtyRowOnlyIfEmpty);
			//} catch(Exception exc) { throw new SmartException(exc); }
		}
	}
}